﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteMaster.Master"
    Inherits="System.Web.Mvc.ViewPage<Telerik.Web.Mvc.GridModel>" %>
<%@ Import Namespace="Microhard.Framework.MVCHelper" %>
<%@ Import Namespace="Microhard.Permission.Interface" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    用户管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="section-header">
        <div class="title">
            <img src="<%=Url.Content("~/Content/images/ico-catalog.png")%>" alt="" />
            用户管理
        </div>
        <div class="options">
        </div>
    </div>
    <table width="100%">
        <tr>
            <td class="adminTitle">
                <img alt="用户名" src="<%=Url.Content("~/Content/images/ico-help.gif") %>" title="用户名" />
                <label for="userName" title="用户名">
                    用户名</label>:
            </td>
            <td class="adminData">
                <%=Html.TextBox("SearchName")%>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <img alt="角色名" src="<%=Url.Content("~/Content/images/ico-help.gif") %>" title="角色名" />
                <label for="roleName" title="角色名">
                    角色名</label>:
            </td>
            <td class="adminData">
                <%Html.RenderAction("GetSelectList", "Role", new Microhard.WebUI.Models.AttriubteOfSelectList { ParameterModelName = "SearchRoleID", IsMulitiplySelect = false });%>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
        </tr>
    </table>
    <p>
    </p>
    <table class="adminContent">
        <tr>
            <td>
                <%Html.Telerik().Grid<Microhard.Permission.Models.User>((List<Microhard.Permission.Models.User>)this.Model.Data)
                    .Name("us-grid")
                         .ClientEvents(events => events.OnDataBinding("UserGridOnGridDataBinding"))
                         .ToolBar(t => t.Template(g =>
                    { 
                %>
                <%var searchParms = new Dictionary<string, string>();
                  searchParms.Add("UserName", "SearchName");
                  searchParms.Add("Roles[0].RoleId", "SearchRoleID");
                %>
                <div class="header-menu">
                    <ul class="t-widget t-reset t-header t-menu">
                        <li class="t-item  t-state-default">
                            <%=Html.Authorized_SearchButton("btnSearch", "查询", "us-grid", searchParms, "UserGridOnGridDataBinding")%>
                        </li>
                        <li class="t-item  t-state-default">
                            <%=Html.Authorized_AddButton("btnAdd","添加","Create","User") %>
                        </li>
                        <li class="t-item  t-state-default">
                            <%=Html.Authorized_UpdateButton("btnUpdate","修改","us-grid","Update","User","admin")%>
                        </li>
                        <li class="t-item  t-state-default">
                            <%=Html.Authorized_DeleteButton("btnDelete","删除","us-grid","Delete","User") %>
                        </li>
                    </ul>
                </div>
                <%}))
                         .Columns(columns =>
                    {
                        columns.Bound(x => x.UserName)
                       .Template(x => Html.CheckBox("checkedRecords", new { value = x.ID, @class = Html.GridSelectingUsedCSS() }))
                       .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= ID #>' class='" + Html.GridSelectingUsedCSS() + "'/>")
                     .HtmlAttributes(new { style = "text-align:center" }).Title("选择");

                        columns.Bound(x => x.UserName).Title("用户名");
                        columns.Bound(x => x.DisplayRoles).Title("角色");
                        columns.Bound(x => x.Email).Title("邮箱地址");

                    })
                      .Pageable(settings => settings.Total(Model.Total).PageSize(Html.GetGridPageSize()).Position(GridPagerPosition.Top))
                      //绑定搜索按钮，执行对应的action
                    .DataBinding(dataBinding => dataBinding.Ajax().Select("_List", "User"))
                    .EnableCustomBinding(true)
                    .Render();
                %>
            </td>
        </tr>
    </table>
</asp:Content>
